package Utils;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class StringsUtil {
    public static String getRandomString(int length){
        String baseString="qwertyuioplkjhgfdsazxcvbnm";
        baseString += baseString.toUpperCase()+"1234567890";
        String[] baseSimpleStrArray=baseString.split("");
        List<String> tmpList= new ArrayList<String>(baseSimpleStrArray.length);
        Collections.addAll(tmpList, baseSimpleStrArray);
        Collections.shuffle(tmpList);
        String tmp="";
        for (String str : tmpList){
            tmp += str;
        }
        Random r=new Random();
        int random = r.nextInt(tmp.length() - length - 1);
        return tmp.substring(random, random+length);
    }
    public static String getStringBySize(int data,int length){
        String format="";
        for (int i=0;i<length;i++){
            format += "0";
        }
        DecimalFormat decimalFormat=new DecimalFormat(format);
        return decimalFormat.format(data);
    }
    public static String getRandomPhone_11(){
        String[] prefix=new String[]{"130","131","132","133","134","135","136","137","138","139","150",
                "151","152","153","154","155","156","157","158","159","160","161","162","163","164",
                "165","166","167","168","169","170","171","172","173","174","175","176","177","178",
                "179","180","181","182","183","184","185","186","187","188","189","190","191","192",
                "193","194","195","196","197","198","199"};
        String suffix=getStringBySize(new Random().nextInt(99999999), 8);
        return prefix[new Random().nextInt(prefix.length)]+suffix;
    }
    public static String getEmailByPrefix(String prefix){
        String[] suffix=new String[]{"@qq.com","@gmail.com","@yahoo.com","@hotmail.com","@aol.com","@ask.com",
                "@live.com","@0355.com","@163.com","@263.com","@yeah.com","@googlemail.com",
                "@mail.com","@msn.com","@aim.com","@netvigator.com",
                "@hknet.com","@mail.h.com","@BIZNETVIGATOR.com"};
        return prefix+suffix[new Random().nextInt(suffix.length)];
    }
}
